<?php include 'header.php'; ?>
	<?php 
	
		if ($_SERVER[REQUEST_METHOD] == "GET")
		{
			$search = htmlspecialchars($_GET["search"]);
			$ID = htmlspecialchars($_GET["ID"]);
			
			if (($_SESSION["user"] != $search) && !in_array($_SESSION["user"], $reviewers)) {
				echo "You do not have permission to view this page.";
				require("footer.php");
				die;
			}
			
			$con = mysqli_connect ("db.cse.unt.edu", 'acmrepo', 'B8cpU6GBx9qJJmN8', 'acmrepo');

			if (mysqli_connect_errno()) {
			  echo "Failed to connect to MySQL: " . mysqli_connect_error();
			}
			
			$query = "select title, link, abstract_text, uploadedAbstractID, first_name, last_name, email, dept_name, univ_name, advisor, acm_id, sig_bio from abstract natural join author where username='" . $search . "' AND abstractID='" . $ID . "'";
			if ($result = mysqli_query($con, $query)) {
				$row = mysqli_fetch_array($result);
					echo "<h1>" . $row['title'] . "</h1>" . "<br><br>";
					
					echo "<h3><i><u>Personal Information: </u></i></h3>";
						echo "<b>Student Name: </b>" . $row['first_name'] . " " . $row['last_name'] . "<br>";
						echo "<strong>Email Address: </strong> " . "<a style=color:#0000af; href=mailto:" . $row['email'] . ">" . $row['email'] . "</a>" . "<br><br>";
	
					echo "<h3><i><u>Academic Information: </u></i></h3> <b>University: </b> " . $row['univ_name'] . "<br> <b>Department:</b> " . $row['dept_name'] . "</br>";
						echo "<b>Advisor:</b> " . $row['advisor'] . "<br><br>";
						echo "<b>ACM ID:</b> " . $row['acm_id'] . "<br>";
					

					if ($row['sig_bio'] == 1)
						echo " Member of SIG BIO? <b>Yes</b>";
					else
						echo " Member of SIG BIO? <b>No</b>";
					

					echo "<br><br><br>" . "<h3>Abstract</h3>";
					
					if (!empty($row['uploadedAbstractID']))
						echo "<a href = getFile.php?id=" . $row['uploadedAbstractID'] . "> Download Abstract (PDF) </a><br>";
					
					if (!empty($row['abstract_text'])) {
						echo "<br><strong>Comments</strong><br>";
						echo $row['abstract_text'];
					
					}
			
					if (!empty($row['link']))
						echo "</br></br><strong>Link to full dissertation</strong><br> <a href = " . $row['link'] . " >" . $row['link'] . " </a></br>";
			}	
		}
	?>
<?php include 'footer.php'; ?>